home *** CD-ROM | disk | FTP | other *** search
- Path: ubnsrv.unisource.ch!news
- From: Fabienne Guinnard <guinnard_f@scopus.ch>
- Newsgroups: comp.lang.c++
- Subject: Virtuals in constructor
- Date: Tue, 20 Feb 1996 22:17:38 +0100
- Organization: HelpDesign
- Message-ID: <312A3A72.688D@scopus.ch>
- NNTP-Posting-Host: user5.scopus.ch
- Mime-Version: 1.0
- Content-Type: text/plain; charset=us-ascii
- Content-Transfer-Encoding: 7bit
- X-Mailer: Mozilla 2.0GoldB1 (Win95; I)
-
- Hi,
-
- does anyone know why the following code doesn't work ?
-
- Run-time error: pure virtual function called
-
- class A
- {
- public:
- A(VOID) { Method(); }
-
- virtual VOID Method(VOID) = 0;
- };
-
- class B : public A
- {
- public:
- B(VOID) {}
-
- VOID Method(VOID) { MessageBox(NULL, "", "", MB_OK); }
- };
-
- int WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
- {
- B b;
-
- return 0;
- }
-
- Thanks
-
- Laurent Guinnard
- guinnard@eig.unige.ch
-
- be_well++;
-